// app.js
import {
  publisher
} from "./utils/login-sdk.js";
App({
  onLaunch() {
    wx.loadFontFace({
      family: 'titleFont',
      global: true,
      source: 'https://aa.snzo.cn/assets/font/STXINGKA.TTF',
    })
    wx.getStorage({
      key: 'userInfo',
      success: (res) => {
        setTimeout(() => {
          const userInfo = res.data;
          this.globalData.userInfo = JSON.parse(userInfo);
          publisher.emit('login');
        }, 100);
      },
      fail: () => {
        setTimeout(() => {
          publisher.emit('login');
        }, 100);
      }
    })
    wx.getStorage({
      key: 'token',
      success: (res) => {
        this.globalData.token = res.data
      }
    })
  },

  globalData: {
    userInfo: null,
    token: null,
    tabbarIndex: 0
  }
})
